package com.xiangxiao.rpan.authority.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xiangxiao.rpan.authority.tree.TreeNode;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/3/29 14:36
 */
@Data
public class ModuleQueryDto implements Serializable, Cloneable, TreeNode {
  private static final long serialVersionUID = -3534603005317156062L;

  private Long id;

  private String name;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date createTime;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date updateTime;

  private Long parentId;

  private int sort;

  private boolean hashChild = false;
  /**
   * 是否选中 true：选中 false:不选中
   */
  private boolean ifChecked = false;

  private List<TreeNode> nextList;

  private List<TreeNode> childList;

  private Long mid;

  private String mname;

  private String resourceCode;

//  private List<ModuleButtonDict> buttonList;

  private List<Long> selectedButtonIds;
  /**
   * 是否只读,默认读写:false
   */
  private Boolean readOnly = false;

  @Override
  public TreeNode copyWithoutTreeInfo() {
    try {
      ModuleQueryDto treeNode = (ModuleQueryDto) super.clone();
      treeNode.childList = new ArrayList<>();
      return treeNode;
    } catch (CloneNotSupportedException e) {
      return null;
    }

  }

  @Override
  public boolean getHasChild() {
    return hashChild;
  }

  @Override
  public void setHasChild(boolean hasChild) {
    this.hashChild = hashChild;
  }
}
